Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky Observer tests using fake clock #3318

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

williamckha
Copy link
Contributor

Description

The tests in observer_test.cpp that call helper function testGetDataReceivedPerSecondByFillingBuffer are flaky in CI because they rely on the passage of actual time.

This PR adds a FakeClock that simulates the passage of time and can be substituted for any std::chrono clock. The time point of FakeClock is fixed and can be explicitly advanced forward with FakeClock::advance. Observer now has a template arg that specifies the clock to use (default is std::chrono::steady_clock) which enables usage of FakeClock in observer_test.cpp.

Testing Done

  • observer_test.cpp passes
  • Added fake_clock_test.cpp

Resolved Issues

Resolves #3309

Length Justification and Key Files to Review

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix flaky Observer test
1 participant